package com.xw.service.xw.caseOrder;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xw.dao.DaoSupport;
import com.xw.entity.Page;
import com.xw.service.xw.cfOrder.CfOrderService;
import com.xw.util.PageData;

/**
 * 类名称: CaseOrderService
 * 类描述: 病历单业务接口
 * @author : gce
 * @date   : 2017-11-30
 */
@Service("caseOrderService")
public class CaseOrderService {
	
	@Resource(name = "daoSupport")
	private DaoSupport dao;
	@Resource(name="cfOrderService")
	private CfOrderService cfOrderService ;
	
	/**
	 * 添加病历单
	 * @param pd
	 * @return: void
	 * @author: gce
	 * @throws Exception 
	 * @date  : 2017-11-30
	 */
	public void save(PageData pd) throws Exception{
		dao.save("CaseOrderMapper.save", pd);
	}
	

	/**
	 * 查询病历单数据（病历单id查询）#{id}
	 * @param pd
	 * @throws Exception
	 * @return: PageData
	 * @author: gce
	 * @date  : 2017-12-7
	 */
	public PageData findById(PageData pd) throws Exception {
		return (PageData) dao.findForObject("CaseOrderMapper.findById", pd);
	}
	
	/**
	 * 删除病历单（修改状态,后修改对应处方单状态） #{id}
	 * @param pd
	 * @throws Exception
	 * @return: int
	 * @author: gce
	 * @date  : 2017-12-7
	 */
	public int delete(PageData pd) throws Exception {
		 return (int)dao.delete("CaseOrderMapper.delete", pd) + (int)cfOrderService.deleteByCaseId(pd);
	}
	
	/**
	 * 查询病例列表：或患者id:#{pd.hzId}、或患者姓名name、或患者电话phone
	 * @param page
	 * @throws Exception
	 * @return: List<PageData>
	 * @author: gce
	 * @date  : 2017-12-6
	 */
	public List<PageData> list(Page page) throws Exception {
		return (List<PageData>) dao.findForList("CaseOrderMapper.listPage", page);
	}

}
